package com.woniu.controller;

import com.woniu.util.HttpStatus;
import com.woniu.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionAdvice extends BaseController{
    @ExceptionHandler
    public Result exceptionResole(Exception exception){
        log.debug("系统出bug了，exception ===== " + exception.getMessage());
        // 打印异常，方面错误排查
        exception.printStackTrace();
        return new Result(HttpStatus.ERROR, exception.getMessage());
    }
}
